package com.zhouxiaoge.quartz.jobs;

import com.github.pagehelper.PageInfo;
import com.zhouxiaoge.quartz.model.JobAndTrigger;
import com.zhouxiaoge.quartz.service.BaseJob;
import com.zhouxiaoge.quartz.service.IJobAndTriggerService;
import com.zhouxiaoge.quartz.tool.SpringUtil;
import org.quartz.JobExecutionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component("helloJob")
public class HelloJob implements BaseJob {

    private static Logger log = LoggerFactory.getLogger(HelloJob.class);

    public HelloJob() {

    }

    @Override
    public void execute(JobExecutionContext context) {
        IJobAndTriggerService iJobAndTriggerService = (IJobAndTriggerService) SpringUtil.getBean("IJobAndTriggerServiceImpl");
        PageInfo<JobAndTrigger> jobAndTriggerDetails = iJobAndTriggerService.getJobAndTriggerDetails(1, 10);
        System.out.println(jobAndTriggerDetails.getTotal());
        log.info("Hello Job执行时间: " + new Date());
    }

}

